package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.base.cebCustoms.request.CebCustomsQueryRequest;
import com.dwms.entity.base.cebCustoms.request.CebCustomsRequest;
import com.dwms.entity.base.cebCustoms.response.CebCustomsResponse;
import com.dwms.entity.base.sellerInfo.request.SellerInfoQueryRequest;
import com.dwms.entity.base.sellerInfo.response.SellerInfoResponse;
import com.dwms.feign.base.CebCustomsFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: CebCustomsController
 * @Description: CebCustoms
 * @Create 2025-08-29 17:40:48
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "关区管理")
@RestController
@RequestMapping(value = "/base/cebCustoms")
@RequiredArgsConstructor
public class CebCustomsController {

    private final HttpServletRequest request;
    private final CebCustomsFeignClient cebCustomsFeignClient;

    /**
     * 保存
     *
     * @param cebCustomsRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "新增关区")
    @PostMapping("/save")
    public Result save(@RequestBody CebCustomsRequest cebCustomsRequest) {
        WebUtil.getAdminRequest(request,cebCustomsRequest);
        return cebCustomsFeignClient.save(cebCustomsRequest);
    }

    /**
     * 修改
     *
     * @param cebCustomsRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改关区")
    @PostMapping("/update")
    public Result update(@RequestBody CebCustomsRequest cebCustomsRequest) {
        WebUtil.getAdminRequest(request,cebCustomsRequest);
        return cebCustomsFeignClient.update(cebCustomsRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<CebCustomsResponse>> findPage(@RequestBody CebCustomsQueryRequest query) {
        WebUtil.getAdminRequest(request,query);
        return cebCustomsFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request,query);
        return this.cebCustomsFeignClient.findById(query);
    }

    /**
     * 删除
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "删除关区")
    @PostMapping("/delete")
    public Result delete(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request,query);
        return this.cebCustomsFeignClient.delete(query);
    }

    /**
     * 查询列表
     * @param query
     * @return
     */
    @Operation(summary = "查询列表")
    @PostMapping("/findList")
    public Result<List<CebCustomsResponse>> findList(@RequestBody CebCustomsQueryRequest query) {
        WebUtil.getAdminRequest(request,query);
        return this.cebCustomsFeignClient.findList(query);
    }

}
